use GRID::Machine;
use Test::More tests => 5;

BEGIN { use_ok('Batch::Cluster::Result') };


# Probando la sobrecarga de la conversión a buleano.
{
  my $r = Batch::Cluster::Result->new();
  $r->add_result(GRID::Machine::Result->new(results => [$_])) for (1..3);
  ok($r, "All with true results");
  $r->add_result(GRID::Machine::Result->new(results => [0]));
  ok(!$r, "All with true results except a false result");
}

# Probando la inserción desordenada.
{
  my $r = Batch::Cluster::Result->new();
  $r->add_result(GRID::Machine::Result->new(results => [ $_ ])) for reverse(0..3);
  my @res = map { $_->result() } $r->all_results();
  my @expected = reverse(0..3); 
  is(@res, @expected, "Unordered insertion");
}

# Probando la inserción ordenada.
{
  my $r = Batch::Cluster::Result->new();
  $r->add_ordered_result(GRID::Machine::Result->new(results => [ $_ ]), $_) for reverse(0..3);
  my @res = map { $_->result() } $r->all_results();
  my @expected = (0..3); 
  is(@res, @expected, "Ordered insertion");
}
